#include <func.h>
#include "head.h"

int removeFile(int sockFd){
    char result;
    recv(sockFd, &result, 1, MSG_WAITALL);
    if(result == '1'){
        puts("can't remove");
    }
    return 0;
}

int cd(int sockFd){
    char result = 0;
    recv(sockFd, &result, 1, 0);
    if(result == '1'){
        puts("no such path");
    }
    return 0;
}

int ls(int sockFd){
    int dataLength;
    char buf[1024] = {0};
    recvn(sockFd, &dataLength, sizeof(dataLength));
    recvn(sockFd, buf, dataLength);
    puts(buf);
    return 0;
}

int pwd(int sockFd){
    int dataLength;
    char buf[1024] = {0};
    recv(sockFd, &dataLength, sizeof(dataLength), 0);
    recv(sockFd, buf, dataLength, 0);
    puts(buf);
    return 0;
}

int makedir(int sockFd){
    char result;
    recv(sockFd, &result, 1, 0);
    if(result == '0'){
        puts("makedir failed");
    }
    return 0;
}

int removedir(int sockFd){
    char result;
    recv(sockFd, &result, 1, MSG_WAITALL);
    if(result == '1'){
        puts("can't remove");
    }
    return 0;
}